package linux;

import com.jcraft.jsch.Session;

import java.util.Arrays;
import java.util.List;

/**
 * @description: TODO
 * @author: wzj
 * @create: 2019/4/12 13:43
 */
public class Main {
    public static void main(String[] args) {
//        LinuxUtils linuxUtils=new LinuxUtils();
//
//        boolean bool=linuxUtils.openConn("192.168.1.128",22,"root","123456");
//        if(bool){
//            System.out.println(123);
////            linuxUtils.exeCmd("chmod +x /home/WRF/rundir/start-wrf.sh");//赋予可执行权限
////            linuxUtils.exeCmd("cd /home/WRF/rundir;./start-wrf.sh");
//            System.out.println(linuxUtils.exeCmdOut("cd /home/WRF/rundir;ll"));
////            System.out.println(linuxUtils.exeCmdOut("cd /home/WRF/rundir;chmod +x start-wrf.sh;./start-wrf.sh"));
//        }
//        linuxUtils.closeConn();

        Session session= LinuxUtils2.getJSchSession("root","192.168.1.128","123456",22);
        if(session!=null){
            String[] strs={"/home/WRF/rundir/run/1.txt","/home/WRF/rundir/run/2.txt","/home/WRF/rundir/run/3.txt","/home/WRF/rundir/run/4.txt","/home/WRF/rundir/run/5.txt","/home/WRF/rundir/run/6.txt","/home/WRF/rundir/run/7.txt","/home/WRF/rundir/run/8.txt"};
            List<String> list= Arrays.asList(strs);
            try {
                LinuxUtils2.execCommandByJSch(session,"rm /home/WRF/rundir/run1");
            } catch (Exception e) {
                e.printStackTrace();
            }
            LinuxUtils2.closeJSchSession(session);
        }
        else {
            System.out.println("连接超时");
        }
    }
}
